#include <uf_draw.h>
#include <stdlib.h>
#include <stdio.h>
#include <uf.h>
#include <uf_draw.h>
#include "uf_part.h"
#include "uf_obj.h"
#include "uf_drf.h"
#include "uf_assem.h"
#include "uf_view.h"


/* ARGSUSED */
void ufusr(char *param, int *retcod, int param_len)
{
    int ifail = 0;
   tag_t drawing_tag;
    char error_message[MAX_LINE_SIZE + 1];
    char drawing_name[MAX_ENTITY_NAME_SIZE] = "SUCCESS";
    UF_DRAW_info_t drawing_info;

    ifail = UF_initialize();

    if( !ifail )
        ifail = UF_DRAW_ask_current_drawing( &drawing_tag );

    /* Get the drawing information from the current drawing. */
    if( !ifail )
        ifail = UF_DRAW_ask_drawing_info( drawing_tag, &drawing_info );

      FILE                  *file1;
	  file1 = fopen("AskDrawinfo.dat","w+");

      fprintf(file1, "The value of the drawing info structure is.\n" );
      fprintf( file1,"size_state:  %d\n", drawing_info.size_state );
      if(drawing_info.size_state == UF_DRAW_METRIC_SIZE )
          fprintf( file1,"standard metric size %d\n",drawing_info.size.metric_size_code );
      else if(drawing_info.size_state == UF_DRAW_ENGLISH_SIZE )
          fprintf( file1,"standard english size %d\n",drawing_info.size.english_size_code );
      else
         fprintf(file1,"custom size = %f,  %f\n",drawing_info.size.custom_size[0],drawing_info.size.custom_size[1] );
         fprintf( file1,"scale:  %f\n", drawing_info.drawing_scale );
      if(drawing_info.projection_angle ==UF_DRAW_THIRD_ANGLE_PROJECTION )
          fprintf(file1," projection angle : third \n" );
      else
          fprintf(file1," projection angle : first \n" );

      fprintf(file1,"\n" );



    if( !ifail && drawing_tag != NULL_TAG )
   {
       drawing_info.size_state = UF_DRAW_CUSTOM_SIZE;
       drawing_info.size.custom_size[0] = 630.0;
       drawing_info.size.custom_size[1] = 945.0;
       drawing_info.drawing_scale = 1.5;
       drawing_info.units = UF_PART_ENGLISH;
      
       ifail = UF_DRAW_set_drawing_info( drawing_tag, &drawing_info);

  }

      fprintf(file1, "The value of the drawing info structure is.\n" );
      fprintf( file1,"size_state:  %d\n", drawing_info.size_state );
      if(drawing_info.size_state == UF_DRAW_CUSTOM_SIZE )
          fprintf( file1,"standard custom size %d\n",drawing_info.size.metric_size_code );
      else if(drawing_info.size_state == UF_DRAW_ENGLISH_SIZE )
          fprintf( file1,"standard english size %d\n",drawing_info.size.english_size_code );
      else
         fprintf(file1,"custom size = %f\n",drawing_info.size.custom_size[0] );
         fprintf(file1,"custom size = %f\n",drawing_info.size.custom_size[1] );
         fprintf( file1,"scale:  %f\n", drawing_info.drawing_scale );
      if(drawing_info.units == UF_PART_ENGLISH)
          fprintf(file1," units : UF_PART_ENGLISH \n" );
      if(drawing_info.projection_angle ==UF_DRAW_THIRD_ANGLE_PROJECTION )
          fprintf(file1," projection angle : third \n" );
      else
          fprintf(file1," projection angle : first \n" );

    ifail = UF_terminate();
   fclose(file1);

}